﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Maxcoderz.GameObjects
{
    public class Map
    {
        private List<Block> _blocks = new List<Block>();

        public List<Block> Blocks
        {
            get { return _blocks; }
        }

        public void Draw()
        {
            foreach (Block block in _blocks)
            {
                block.Draw();
            }
        }

        public Block GetBlock(Vector2 _mouseLocation)
        {
            Rectangle mouseRect = new Rectangle((int)_mouseLocation.X, (int)_mouseLocation.Y, 1, 1);

            for (int i = _blocks.Count-1; i >= 0; i--)
            {
                if (mouseRect.Intersects(_blocks[i].GetDestinationRectangle()))
                {
                    return _blocks[i];
                }
            }

            return null;
        }
    }
}
